<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" /> 
    <title>简易网页版爱吃屎的周建忠</title>
    <script language="javascript" type="text/javascript">
    var i;
    var l =0; var m =0; var y = document.getElementById("c");
        function display(){
          var y = document.getElementById("b");
          //y.src="1.jpg";
          document.getElementById('jsq').innerHTML="0:00";
          document.getElementById('df').innerHTML="0";
          y.style.height="1080px";
          y.style.which="1960px";
        }
var m=10;
var l=0;
var x=0;
var df=0;
var s="dmove();";
var t1,t2,t3,t4,t5;
function getKey(e){ 
  var q = document.getElementById("c1");
  e = e || window.event; 
  var keycode = e.which ? e.which : e.keyCode;
  var r= document.getElementById("t");
  if(keycode == 87||keycode == 119 ){               //如果按下w键 
    var y = document.getElementById("c");
    if(l>0){
      clearTimeout(t2);  
      clearTimeout(t1);
         s="wmove();"; 
      t1=setTimeout(s,1);
    }
  } else if(keycode == 65||keycode == 97){           //如果按下a键 
      var y = document.getElementById("c");
        if(x>0){
         clearTimeout(t1);clearTimeout(t2); 
         s="amove();";t1=setTimeout(s,1);
        }
    }else if(keycode == 83||keycode == 115){        //如果按下s键 
      var y = document.getElementById("c");
      if(l<650){
        clearTimeout(t1);clearTimeout(t2); 
         s="smove();"; 
         t1=setTimeout(s,1);
      }
}else if(keycode == 68||keycode == 100){          //如果按下d键 
    var y = document.getElementById("c");
      if(x<1050){
      //x=x+50;
      //y.style.left=x+'px'; 
      clearTimeout(t2);  
      clearTimeout(t1);
         s="dmove();"; 
         
    t1=setTimeout(s,1);
    }
  }
} 
function eat(){
  var w=Math.floor(Math.random() * ( 21 + 1))*50;
  var h=Math.floor(Math.random() * ( 13 + 1))*50;
  var q = document.getElementById("c1");
  q.style.top=h+'px';
  q.style.left=w+'px';
}
function change(){
  var q = document.getElementById("bg");
  var y = document.getElementById("b");
          y.src=q.value;
}
function change1(){
  var q = document.getElementById("zc");
  var y = document.getElementById("b1");
          y.src=q.value;
}
document.onkeypress=getKey;                 //实现倒计时
var wait=60;                                
function time() {                              
  var j=document.getElementById("jsq");
  if (wait == 0) { 
  //j.removeAttribute("disabled"); 
  //wait = 60; 
  clearTimeout(t1);
  } else { 
    //j.setAttribute("disabled", true); 
    jsq.innerHTML=wait ; 
    wait--; 
    t=setTimeout(function() { 
    time() 
    }, 1000) ;
  } 
} 
function time1() {                               //游戏开始
  time();
  //t1=setTimeout(s,1);
} 

function wmove(){            //w蛇移动
  var s1 = document.getElementById("c");
  if(l>0){
  l=l-50;
  s1.style.top=l+'px';
  var q = document.getElementById("c1");
  if(s1.style.top==q.style.top&&s1.style.left==q.style.left){
      eat();
      df=df+10;document.getElementById('df').innerHTML=df;
    } 
  t2=setTimeout("wmove()",1000);}
  else{
  clearTimeout(t);
  }
}
function amove(){          //a蛇移动
  var s1 = document.getElementById("c");
  if(x>0){
  x=x-50;
  s1.style.left=x+'px';
  var q = document.getElementById("c1");
  if(s1.style.top==q.style.top&&s1.style.left==q.style.left){
      eat();
      df=df+10;document.getElementById('df').innerHTML=df;
    } 
  t2=setTimeout("amove()",1000);}
  else{
  clearTimeout(t);
  }
}
function smove(){          //s蛇移动
  var s1 = document.getElementById("c");
  if(l<650){
  l=l+50;
  s1.style.top=l+'px';
  var q = document.getElementById("c1");
  if(s1.style.top==q.style.top&&s1.style.left==q.style.left){
      eat();
      df=df+10;document.getElementById('df').innerHTML=df;
    } 
  t2=setTimeout("smove()",1000);}
  else{
  clearTimeout(t);
  }
}
function dmove(){           //d蛇移动
  var s1 = document.getElementById("c");
  if(x<1050){
  x=x+50;
  s1.style.left=x+'px';
  var q = document.getElementById("c1");
  if(s1.style.top==q.style.top&&s1.style.left==q.style.left){
      eat();
      df=df+10;document.getElementById('df').innerHTML=df;
    } 
  t2=setTimeout("dmove()",1000);}
  else{
  clearTimeout(t);
  }
}

</script>
</head>
<body onload="display()">
<div id="t"  align="center">
<img  src="1.jpg" id="b"  style="position: absolute; left: 0px;top: 0px" />
</div>
<div style="width:1100px;height: 700px ;position: absolute; left: 100px;top: 100px;border:solid;"><img src="z3.jpg"  id="b1"  /><!-- onclick="sa()" ondblclick="sb()" --><!-- style="width:1100px;height: 700px ;position: relative; left: 0px;top: 0px;"  -->
<div id="c" style="width:50px;height: 50px;position: absolute; left: 0px;top: 0px;"><img src="s.jpg"  id="c" /></div><!-- onclick="pao()" -->
<div id="c1" style="width:50px;height: 50px;position: absolute; left: 100px;top: 100px;" ><img src="bb.jpg"  /></div>
</div>
<div style="position: absolute; left: 1300px;top: 100px;">
<select id="bg" style="width:150px;height: 50px;">
    <option value="1.jpg" selected="selected">1.jpg</option>
    <option value="2.jpg">2.jpg</option>
    <option value="3.jpg">3.jpg</option>
  </select>
  <input type="button" name="" value="改变主题" onclick="change()" style="width:150px;height: 50px;">
<div style="position: absolute; left: 0px;top: 50px;">
  <select id="zc" style="width:150px;height: 50px;">
    <option value="z1.jpg" selected="selected">死亡峡谷</option>
    <option value="b.jpg">上古战魂</option>
    <option value="z2.jpg">武当</option>
    <option value="z3.jpg">云界</option>
    <option value="z4.jpg">精灵之森</option>
    <option value="z5.jpg">修罗炼狱</option>
  </select>
  <input type="button" name="" value="改变战场" onclick="change1()" style="width:150px;height: 50px;">
  </div>
  <div><input id="jb" type="button" name="" value="开始游戏" onclick="time1()" style="width:150px;height: 50px;position: absolute; left: 160px;top: 150px;"></div> 
  <div style="font-size:50px;"><label id="jsq" style="position: absolute; left: 0px;top: 150px;width:150px;height: 50px;" ></ label> </div>
  <div style="font-size:50px;"><label  style="position: absolute; left: 0px;top: 250px;width:150px;height: 50px;" >得分:</ label> <label id="df" style="width:150px;height: 50px;position: absolute; left: 160px;top: 0px;" ></ label> </div>
</body>
</html>
